**********************************************
* VIOLENT COMPETITION AND TERRORIST RESTRAINT
* 
* Sara M.T. Polo (University of Essex)
* sara.polo@essex.ac.uk
*
* Blair Welsh (NYU - Abu Dhabi)
* blairwelsh@nyu.edu
*
* International Organization, 2024
**********************************************

* Change to respective directory
cd "/Users/bjw9936/Desktop/Polo_Welsh_IO/02_Appendix"

**********************************************
* APPENDIX FILES
**********************************************

* Macro-Level Reported Tests
use main.dta, clear
xtset newid iyear

* Table A4 (Models 1-3): Macro-Level Results
glm softratio infight_b, family(binomial) link(logit) cluster(gtdname)
glm softratio infight_b nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio_lag, family(binomial) link(logit) cluster(gtdname)
glm softratio infight_b nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio_lag size ln_gdp ln_pop pts_a efindex, family(binomial) link(logit) cluster(gtdname)

* Table A4 (Models 4-6): Macro-Level Results
glm softratio ln_infight, family(binomial) link(logit) cluster(gtdname)
glm softratio ln_infight nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio_lag, family(binomial) link(logit) cluster(gtdname)
glm softratio ln_infight nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio_lag size ln_gdp ln_pop pts_a efindex, family(binomial) link(logit) cluster(gtdname)

* Micro-Level Reported Tests
use syria.dta, clear
xtset id modate

* Table A5: Micro-Level District-Month Analysis on ISIS in Syria
xtreg softratio infight_b softratiolag i.iyear, fe vce(cluster id)
xtreg softratio infight_b deathsb attacks territory tax_index services_index softratiolag i.iyear, fe vce(cluster id)

* Macro-Level Robustness Tests
use main.dta, clear
xtset newid iyear

* Table A6: Ordinal Measure of Infighting
glm softratio infight_o, family(binomial) link(logit) cluster(gtdname)
glm softratio infight_o nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio_lag, family(binomial) link(logit) cluster(gtdname)
glm softratio infight_o nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio_lag size ln_gdp ln_pop pts_a efindex, family(binomial) link(logit) cluster(gtdname)

* Table A7: Linear Model Specification
xtreg softratio infight_b nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio_lag i.iyear, cluster(gtdname) fe
xtreg softratio infight_b nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio_lag size ln_gdp ln_pop pts_a efindex i.iyear, cluster(gtdname) fe
xtreg softratio ln_infight nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio_lag i.iyear, cluster(gtdname) fe
xtreg softratio ln_infight nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio_lag size ln_gdp ln_pop pts_a efindex i.iyear, cluster(gtdname) fe

* Table A8: Alternative Dependent Variable: Count
regress softx infight_b nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio_lag, cluster(gtdname)
regress softx ln_infight nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio_lag, cluster(gtdname)

* Table A9: Alternative Dependent Variable: Binary
logit softx_binary infight_b nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio_lag, cluster(gtdname)
logit softx_binary ln_infight nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio_lag, cluster(gtdname)

* Table A10: Alternative Dependent Variable: Poisson with Fixed Effects
use mgar_groupyear.dta, clear
xtpoisson attacks enemies_b competition_b attacks_lag, fe
xtpoisson civilians enemies_b competition_b attacks_lag, fe

* Table A11: Removal of Military Targets
use main.dta, clear
xtset newid iyear
glm softratio2 infight_b nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio2_lag, family(binomial) link(logit) cluster(gtdname)
glm softratio2 infight_b nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio2_lag size ln_gdp ln_pop pts_a efindex, family(binomial) link(logit) cluster(gtdname)
glm softratio2 ln_infight nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio2_lag, family(binomial) link(logit) cluster(gtdname)
glm softratio2 ln_infight nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio2_lag size ln_gdp ln_pop pts_a efindex, family(binomial) link(logit) cluster(gtdname)

* Table A12: Reduced Sample without Syria
glm softratio infight_b nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio_lag, family(binomial) link(logit) cluster(gtdname), if country != "Syria"
glm softratio infight_b nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio_lag size ln_gdp ln_pop pts_a efindex, family(binomial) link(logit) cluster(gtdname), if country != "Syria"
glm softratio ln_infight nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio_lag, family(binomial) link(logit) cluster(gtdname), if country != "Syria"
glm softratio ln_infight nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio_lag size ln_gdp ln_pop pts_a efindex, family(binomial) link(logit) cluster(gtdname), if country != "Syria"

* Table A13: Competition Measured with MGAR
xtreg softratio enemies_b competition_b nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio_lag i.iyear, cluster(gtdname) fe

* Table A14: Brutality of Competitors and Partners
glm softratio infight_b nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio_lag softratio_country_lag, family(binomial) link(logit) cluster(gtdname)
glm softratio ln_infight nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio_lag softratio_country_lag, family(binomial) link(logit) cluster(gtdname)
glm softratio infight_b nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio_lag prop_ideologicalsoft, family(binomial) link(logit) cluster(gtdname)
glm softratio ln_infight nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio_lag prop_ideologicalsoft, family(binomial) link(logit) cluster(gtdname)

* Table A15: Brutality of Competitors and Partners (Interaction)
glm softratio infight_b##c.softratio_country_lag nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio_lag, family(binomial) link(logit) cluster(gtdname)
glm softratio infight_b##c.prop_ideologicalsoft nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio_lag, family(binomial) link(logit) cluster(gtdname)

* Table A16: Ethnic and Religious Claims
glm softratio infight_b nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio_lag claim religious_claim, family(binomial) link(logit) cluster(gtdname)
glm softratio ln_infight nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio_lag claim religious_claim, family(binomial) link(logit) cluster(gtdname)

* Table A17: Shared Audience
glm softratio infight_b nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio_lag shared_audience, family(binomial) link(logit) cluster(gtdname)
glm softratio ln_infight nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio_lag shared_audience, family(binomial) link(logit) cluster(gtdname)

* Table A18: Ethnic Constituency
glm softratio infight_b nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio_lag, family(binomial) link(logit) cluster(gtdname), if claim == 1
glm softratio infight_b nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio_lag, family(binomial) link(logit) cluster(gtdname), if claim == 0
glm softratio ln_infight nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio_lag, family(binomial) link(logit) cluster(gtdname), if claim == 1
glm softratio ln_infight nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio_lag, family(binomial) link(logit) cluster(gtdname), if claim == 0

* Figure A4
quietly glm softratio i.infight_b nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio_lag, family(binomial) link(logit) cluster(gtdname), if claim == 1
margins i.infight_b, post
coefplot (., keep(0.infight_b) bcolor(bluishgray)) ///
		 (., keep(1.infight_b) bcolor(bluishgray)) /// 
		 , vertical legend(off) nooffsets recast(bar) barwidth(0.8) fcolor(*.8) ///
	   citop ciopts(recast(rcap) lcol(black)) citype() ///
       coeflabels(, notick labgap(2)) plotregion(margin(b=0)) ///
	   ylabel(0.4(0.1)0.7) ytitle(Proportion of Attacks on Soft Targets) ///
	   xlabel(1 "No Violent Competition" 2 "Violent Competition") ///
	   subtitle("Groups with Ethnic Constituency")
graph save "figurea4_1"

quietly glm softratio i.infight_b nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio_lag, family(binomial) link(logit) cluster(gtdname), if claim == 0
margins i.infight_b, post
coefplot (., keep(0.infight_b) bcolor(bluishgray)) ///
		 (., keep(1.infight_b) bcolor(bluishgray)) /// 
		 , vertical legend(off) nooffsets recast(bar) barwidth(0.8) fcolor(*.8) ///
	   citop ciopts(recast(rcap) lcol(black)) citype() ///
       coeflabels(, notick labgap(2)) plotregion(margin(b=0)) ///
	   ylabel(0.4(0.1)0.7) ytitle(Proportion of Attacks on Soft Targets) ///
	   xlabel(1 "No Violent Competition" 2 "Violent Competition") ///
	   subtitle("Groups without Ethnic Constituency")
graph save "figurea4_2"

quietly glm softratio c.ln_infight nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio_lag, family(binomial) link(logit) cluster(gtdname), if claim == 1
margins, at(ln_infight=(0(1)6))
marginsplot, recast(line) recastci(rarea) ///
ciopt(color(bluishgray)) plot1opts(lc(navy) lpattern(solid)) ///
ytitle("Proportion of Attacks on Soft Targets") ///
xtitle("Infighting Attacks (log)") ///
ylab(0(0.1)0.7, nogrid) title("") subtitle("Groups with Ethnic Constituency")
graph save "figurea4_3"

quietly glm softratio c.ln_infight nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio_lag, family(binomial) link(logit) cluster(gtdname), if claim == 0
margins, at(ln_infight=(0(1)6))
marginsplot, recast(line) recastci(rarea) ///
ciopt(color(bluishgray)) plot1opts(lc(navy) lpattern(solid)) ///
ytitle("Proportion of Attacks on Soft Targets") ///
xtitle("Infighting Attacks (log)") ///
ylab(0(0.1)0.7, nogrid) title("") subtitle("Groups without Ethnic Constituency")
graph save "figurea4_4"

graph combine figurea4_1.gph figurea4_2.gph figurea4_3.gph figurea4_4.gph

* Table A19: Foreign Support Interaction
glm softratio infight_b##foreignspon nat left right rel regimetype territory attacks n_group ch_group conflictyear softratio_lag, family(binomial) link(logit) cluster(gtdname)
glm softratio c.ln_infight##foreignspon nat left right rel regimetype territory attacks n_group ch_group conflictyear softratio_lag, family(binomial) link(logit) cluster(gtdname)

use foreign_support.dta, clear 

* Table A20: Foreign Support Interaction (Weapons)
glm softratio infight_b nat left right rel regimetype ext_weapons territory attacks n_group ch_group conflictyear softratio_lag, family(binomial) link(logit) cluster(gtdname)
glm softratio infight_b##ext_weapons nat left right rel regimetype territory attacks n_group ch_group conflictyear softratio_lag, family(binomial) link(logit) cluster(gtdname)

* Table A21: Foreign Support Interaction (Materials)
glm softratio infight_b nat left right rel regimetype ext_materials territory attacks n_group ch_group conflictyear softratio_lag, family(binomial) link(logit) cluster(gtdname)
glm softratio infight_b##ext_materials nat left right rel regimetype territory attacks n_group ch_group conflictyear softratio_lag, family(binomial) link(logit) cluster(gtdname)

* Table A22: Foreign Support Interaction (Training)
glm softratio infight_b nat left right rel regimetype ext_training territory attacks n_group ch_group conflictyear softratio_lag, family(binomial) link(logit) cluster(gtdname)
glm softratio infight_b##ext_training nat left right rel regimetype territory attacks n_group ch_group conflictyear softratio_lag, family(binomial) link(logit) cluster(gtdname)

* Table A23: Foreign Support Interaction (Intelligence)
glm softratio infight_b nat left right rel regimetype ext_intel territory attacks n_group ch_group conflictyear softratio_lag, family(binomial) link(logit) cluster(gtdname)
glm softratio infight_b##ext_intel nat left right rel regimetype territory attacks n_group ch_group conflictyear softratio_lag, family(binomial) link(logit) cluster(gtdname)

* Table A24: Foreign Support Interaction (Territory)
glm softratio infight_b nat left right rel regimetype ext_territory territory attacks n_group ch_group conflictyear softratio_lag, family(binomial) link(logit) cluster(gtdname)
glm softratio infight_b##ext_territory nat left right rel regimetype territory attacks n_group ch_group conflictyear softratio_lag, family(binomial) link(logit) cluster(gtdname)

use main.dta, clear
xtset newid iyear

* Table A25: Lagged Civilian Attacks
glm softratio infight_b##c.civilianslag nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio_lag, family(binomial) link(logit) cluster(gtdname)
glm softratio c.ln_infight##c.civilianslag nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio_lag, family(binomial) link(logit) cluster(gtdname)

* Table A26: Rebel Governance
glm softratio i.infight_b##governance nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio_lag claim religious_claim, family(binomial) link(logit) cluster(gtdname)
glm softratio c.ln_infight##governance  nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio_lag claim religious_claim, family(binomial) link(logit) cluster(gtdname)

* Table A27: Rebel Governance on Terrorist Attacks
regress lnattacks infight_b##governance nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio_lag claim religious_claim, cluster(gtdname)
regress lnattacks c.ln_infight##governance  nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio_lag claim religious_claim, cluster(gtdname)

* Table A28: Conflict Intensity
glm softratio infight_b nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio_lag lndeaths_a lndeaths_b, family(binomial) link(logit) cluster(gtdname)
glm softratio c.ln_infight nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio_lag lndeaths_a lndeaths_b, family(binomial) link(logit) cluster(gtdname)

* Table A29: Non-Violent Mobilization
glm softratio infight_b nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio_lag protest, family(binomial) link(logit) cluster(gtdname)
glm softratio ln_infight nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio_lag protest, family(binomial) link(logit) cluster(gtdname)

* Table A30: Organizational Size (Categorical)
glm softratio infight_b##c.size nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio_lag, family(binomial) link(logit) cluster(gtdname)
glm softratio c.ln_infight##c.size nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio2_lag, family(binomial) link(logit) cluster(gtdname)

* Table A31: Organizational Size (Stronger or Weaker)
glm softratio infight_b##c.size2 nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio_lag, family(binomial) link(logit) cluster(gtdname)
glm softratio c.ln_infight##c.size2 nat left right rel regimetype foreignspon territory attacks n_group ch_group conflictyear softratio2_lag, family(binomial) link(logit) cluster(gtdname)

* Micro-Level Robustness Tests
use syria.dta, clear
xtset id modate

* Table A32: GEE Specification
xtgee softratio infight_b softratiolag i.iyear, family(binomial) link(logit)
xtgee softratio infight_b deathsb attacks territory tax_index services_index softratiolag i.iyear, family(binomial) link(logit)

* Table A33: GLM Specification
glm softratio infight_b softratiolag, family(binomial) link(logit) cluster(id)
glm softratio i.infight_b deathsb attacks territory tax_index services_index softratiolag, family(binomial) link(logit) cluster(id)

* Table A34: Count Measure of Infighting
xtreg softratio ln_infight softratiolag i.iyear, fe vce(cluster id)
xtreg softratio ln_infight deathsb attacks territory tax_index services_index softratiolag i.iyear, fe vce(cluster id)

* Table A35: Removal of Military Targets
xtreg softratio2 infight_b softratio2lag i.iyear, fe vce(cluster id)
xtreg softratio2 infight_b deathsb attacks territory tax_index services_index softratio2lag i.iyear, fe vce(cluster id)

* Table A36: Monthly Fixed Effects
xtreg softratio infight_b softratiolag i.imonth, fe vce(cluster id)
xtreg softratio infight_b deathsb attacks territory tax_index services_index softratiolag i.imonth, fe vce(cluster id)

* Table A37: Alternative Dependent Variable
xtreg soft_b infight_b deathsb attacks territory tax_index services_index softratiolag i.iyear, fe vce(cluster id)
xtreg soft infight_b deathsb attacks territory tax_index services_index softratiolag i.iyear, fe vce(cluster id)

* Table A38: Foreign Civilians Placebo Test
xtreg foreignratio infight_b deathsb attacks territory tax_index services_index softratiolag i.iyear, fe vce(cluster id)
xtreg natcivratio infight_b deathsb attacks territory tax_index services_index softratiolag i.iyear, fe vce(cluster id)

* Table A39: Ethnic Composition of Districts
xtreg softratio infight_b deathsb attacks territory tax_index services_index softratiolag i.iyear, fe vce(cluster id), if sunni == 1
xtreg softratio infight_b deathsb attacks territory tax_index services_index softratiolag i.iyear, fe vce(cluster id), if mixed2 | nonsunni == 1

* Table A40: Brutality of Rivals
xtreg softratio infight_b deathsb attacks territory tax_index services_index softratiolag attacks_comp i.iyear, fe vce(cluster id)
xtreg softratio infight_b deathsb attacks territory tax_index services_index softratiolag soft_comp i.iyear, fe vce(cluster id)

* Table A41: Conditioning on Brutality of Rivals
xtreg soft c.infight##c.soft_comp deaths_is deathsb attacks territory tax_index services_index softratiolag i.iyear, fe vce(cluster id)

* Table A42: Exploring Audience of Rivals
use syria_data_sameaudience.dta, clear
xtset id modate

xtreg ln_deathscivilians l.ln_isinfight l.deaths_is deathsb attacks territory tax_index services_index softratiolag i.iyear, fe vce(cluster id)

use syria_data_nosameaudience.dta, clear
xtset id modate

xtreg ln_deathscivilians l.ln_isinfight l.deaths_is deathsb attacks territory tax_index services_index softratiolag i.iyear, fe vce(cluster id)



